<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>refs的使用</title>
</head>
<body>
    <div id="app">
        <App></App>
    </div>
    <script src="vue.js"></script>
    <script>
        Vue.component('Test',{
            data(){
                return{
                    msg:'小胖子',
                }
            },
            template:`
                <div>
                    <h3>{{msg}}</h3>
                </div>
            `
        })
        const App={
            data(){
                return{

                }
            },
            mounted(){
                console.log(this.$refs.btn);
                this.$refs.input.focus();
                console.log(this.$refs.test);
            },
            components:{},
            template:`
                <div>
                    <Test ref='test'></Test>
                    <button ref='btn'>改变</button>
                    </br>
                    <input type="text" ref='input'/>
                </div>
            `
        }
        new Vue({
            el:'#app',
            data:{

            },
            components:{
                App
            }
        })
    </script>
</body>
</html>